package com.hjj.concurrence.syncBlock.t4;


public class Task {
    public void doLongTimeTask() {
        for (int i = 0; i < 100; i++) {
            System.out.println("nosynchronized threadName=" + Thread.currentThread().getName() + " i=" + (i + 1));
        }
        System.out.println("");
        synchronized (this) {
            for (int i = 0; i < 100; i++) {
                System.out.println("synchronized threadName=" + Thread.currentThread().getName() + " i=" + (i + 1));
            }
        }
    }

    public static void main(String[] args) {
        Task task = new Task();
        new Thread1(task).start();
        new Thread2(task).start();
    }
}
